package com.qding.park.adapter.report.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.qding.park.adapter.report.controller.ReportController;
import com.qding.park.common.utils.qiniu.ImgServiceInPrivate;
import com.qiniu.common.QiniuException;
import com.qiniu.http.Response;

public class ImgUtil {

	private static final Logger logger = LoggerFactory.getLogger(ImgUtil.class);

	public static final String PARK_IN_PIC_DIR = "parkInPic";

	public static final String PARK_OUT_PIC_DIR = "parkOutPic";

	public static String getInPicName(String supplyID, String enInID) {

		return PARK_IN_PIC_DIR + "/" + supplyID + "_" + enInID + ".jpg";
	}

	public static String getOutPicName(String supplyID, String enOutID) {

		return PARK_OUT_PIC_DIR + "/" + supplyID + "_" + enOutID + ".jpg";
	}

	public static String uploadImg(ImgServiceInPrivate imgServiceInPrivate, byte[] data, String fileKey) {

		try {
			Response r = imgServiceInPrivate.UploadImg(data, fileKey);
			data = null;
		} catch (QiniuException e) {
			logger.error(e.getMessage(), e);
			return null;
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			return null;
		}
		data = null;
		return fileKey;
	}
}
